#include "Configure.h"
#include "DataUpdata.h"
#include "Goose.h"
#include "Server.h"
#include "Util.h"
#include "dataShare/include/ApplicationLayer.h"

#include <goose_publisher.h>
#include <hal_thread.h>
#include <iec61850_server.h>
#include <memory>
#include <signal.h>

int main(int argc, char **argv) {
    Util::Init();
    Util::LoadConfiguration();

    Server server;
    server.Init();
    server.Start();

    // Goose goose(INTERFACE_2);
    // goose.Subscribe();

    int count = 0;
    signal(SIGINT, Server::SigintHandler);
    DataUpdate dataUpdata;
    dataUpdata.Init();

    Server::running = true;
    while (Server::running) {
        zlog_w("main loogp: %d, Max Addr: %d", count++, SADDR_MAX_NUM);
        server.Lock();
        dataUpdata.Run();
        server.Unlock();
        Thread_sleep(1000);
    }

    return 0;
} /* main() */
